<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* 用户输入一个数字，判断这个数字是否是质数 */
        var num = prompt("请输入一个数：", );
        var time;
        for(var i = 1; i <= num; i++) {
            if( num % i == 0) {
                time += 1;
            }
        }
        if( time == 2) {
            alert(num + "是质数");
        } else {
            alert(num + "不是质数");
        }
        
    </script>
</body>
</html>